package com.megalith.controller;

import com.megalith.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短信验证码
 * @author lifp
 * @date 2023/06/29
 */
@RestController
@RequestMapping("/message")
@Slf4j
@Api(tags = "短信验证码")
public class MessageValidateController {
    @Autowired
    private MessageService messageService;

    @ApiOperation("发送验证码")
    @PostMapping("send/{userId}/{phoneNumber}")
    public String sendMessage(@PathVariable String userId,@PathVariable String phoneNumber){
        return messageService.sendMessage(userId,phoneNumber);
    }

    @ApiOperation("验证码校验")
    @PostMapping("check/{phone}/{code}")
    public String checkSmsCode(@PathVariable String phone,@PathVariable String code){
        return messageService.checkSmsCode(phone,code);
    }
}
